import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/test01',
  },
  {
    path: '/test01',
    name: 'Test01',
    component: () =>
      import(/* webpackChunkName: "Test01" */ '../views/test01/parent'),
    meta: {
      title: '父传子通信',
    },
  },
  {
    path: '/test02',
    name: 'Test02',
    component: () =>
      import(/* webpackChunkName: "Test02" */ '../views/test02/parent'),
    meta: {
      title: '子传父通信',
    },
  },
  {
    path: '/test03',
    name: 'Test03',
    component: () =>
      import(/* webpackChunkName: "Test03" */ '../views/test03/parent'),
    meta: {
      title: '兄弟间通信-bus',
    },
  },
  {
    path: '/test04',
    name: 'Test04',
    component: () =>
      import(/* webpackChunkName: "Test04" */ '../views/test04/parent'),
    meta: {
      title: '跨组件操作-ref',
    },
  },
  {
    path: '/test05',
    name: 'Test05',
    component: () =>
      import(/* webpackChunkName: "Test05" */ '../views/test05/parent'),
    meta: {
      title: '父链/子链($parent/$children)',
    },
  },
  {
    path: '/test06',
    name: 'Test06',
    component: () =>
      import(/* webpackChunkName: "Test06" */ '../views/test06/parent'),
    meta: {
      title: 'Vuex',
    },
  },
  {
    path: '/test07',
    name: 'Test07',
    component: () =>
      import(/* webpackChunkName: "Test07" */ '../views/test07/parent'),
    meta: {
      title: '$attrs/$listeners',
    },
  },
  {
    path: '/test08',
    name: 'Test08',
    component: () =>
      import(/* webpackChunkName: "Test08" */ '../views/test08/parent'),
    meta: {
      title: 'provide/inject API',
    },
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
})

export default router
